HOOKDIR="/usr/lib/portage/hooks/"

function isfeature () {
        # return 0 if a feature is enabled, 1 otherwise
        local retval=1
        for a in ${FEATURES}; do
                if [[ "$a" == "$1" ]]; then
                        retval=0
                elif [[ "$a" == "-${1}" ]]; then
                        retval=1
        fi
        done
        return ${retval}
}

if [ ! -z ${EBUILD_PHASE} ]
then
        hooks=$(ls "${HOOKDIR}/${EBUILD_PHASE}/" -1)
        for h in ${hooks}
        do
                hook="${HOOKDIR}/${EBUILD_PHASE}/${h}"
                #einfo "Executing hook:" ${hook}
                if [ -x ${hook} ]
                        then
                                source ${hook}
                fi
        done
fi

